<template>
	<view class="content">
		<view class="tishi" v-if="info.switch==1">温馨提示：此次报名会员享受优惠价哦！</view>
		<!-- 活动详情 -->
		<view class="hdXq">
			<view class="hdTitle">
				{{info.hdName}}
			</view>
			<view class="hdText">
				<p>
					<image src="../../static/img/img/time.png" mode="" class="img"></image>
					{{ym}}&nbsp;&nbsp;{{date}}&nbsp;&nbsp;{{startTime}}-{{endTime}}
				</p>
				<p>
					<image src="../../static/img/img/dd.png" mode="" class="img"></image>
					{{info.address}}
				</p>
			</view>
		</view>
		<view class="formBox">
			<page-head title="form"></page-head>
			<view class="uni-padding-wrap uni-common-mt">
				<form>
					<view class="form" v-for="(item, index) in formData" :key="index">
						<image src="../../static/img/del.png" mode="" class="del" v-if="index>0"
							@click="handleDel(index)"></image>
						<view class="uni-form-item uni-column">
							<view class="title">
								<!-- <image src="../../static/sfzh.png" mode="" class="icon"></image> -->
								姓名：
							</view>
							<input class="uni-input" name="name" v-model="formData[index].name" placeholder="请输入真实的姓名" />
						</view>
						<view class="uni-form-item uni-column">
							<view class="title">
								<!-- <image src="../../static/sfzh.png" mode="" class="icon"></image> -->
								身份证号：
							</view>
							<input class="uni-input" name="card" v-model="formData[index].card" placeholder="请输入真实的身份证号" />
						</view>
						<view class="uni-form-item uni-column">
							<view class="title">
								<!-- <image src="../../static/phone.png" mode="" class="icon"></image> -->
								联系电话：
							</view>
							<input class="uni-input" name="phone" v-model="formData[index].phone"
								placeholder="请输入联系电话" disabled v-if="index==0"/>
							<input class="uni-input" name="phone" v-model="formData[index].phone"
									placeholder="请输入联系电话" v-if="index!==0"/>
							<!-- <input class="uni-input" name="phone" v-model="formData[index].phone" placeholder="请输入联系电话" v-if="!formData[index].phone"/> -->
						</view>
					</view>
				</form>
				<!-- <view class="txry" @click="handleAdd" v-if="formData.length<=2&&info.isstart==0"> -->
				<view class="txry" @click="handleopen" v-if="formData.length<=2&&info.isstart==0">
					<view class="jia">
						<image src="../../static/img/jiahao.png" mode="" class="icon"></image>
						<text>我要带搭子</text>
					</view>
				</view>
				<view class="shengming"><text>免责声明：</text>若因您所提供的信息有误而导致保险无法正常理赔或产生其他相关问题，俱乐部将不承担任何责任。</view>
				<checkbox-group @change="checkboxChange" class="xy">
					<label>
						<checkbox value="cb" color="#05bdfd" style="transform:scale(0.7)" />我已阅读并同意免责声明
					</label>
				</checkbox-group>
				<view class="height"></view>
				<view class="uni-btn-v">
					<view class="price">
						<span class="jf" v-if="userIn.grade=='普通用户'||!userIn.grade">￥{{info.price*formData.length}}</span>
						<span class="jf" v-if="userIn.grade=='普通会员'&&formData.length==1">{{info.hyPrice*formData.length}}元</span>
						<span class="jf" v-if="userIn.grade=='普通会员'&&formData.length==2">{{parseFloat(info.hyPrice)+parseFloat(info.price)*0.9}}元</span>
						<span class="jf" v-if="userIn.grade=='普通会员'&&formData.length==3">{{parseFloat(info.hyPrice)+parseFloat(info.price)*0.9+parseFloat(info.price)*0.9}}元</span>
						<span class="jf" v-if="userIn.grade=='尊贵大会员'&&formData.length==1">{{info.dPrice*formData.length}}元</span>
						<span class="jf" v-if="userIn.grade=='尊贵大会员'&&formData.length==2">{{parseFloat(info.dPrice)+parseFloat(info.price)*0.9}}元</span>
						<span class="jf" v-if="userIn.grade=='尊贵大会员'&&formData.length==3">{{parseFloat(info.dPrice)+parseFloat(info.price)*0.9+parseFloat(info.price)*0.9}}元</span>
					</view>
					<button form-type="submit" @click="handleEnroll" class="btn" v-if="hyStatus!=='尊贵大会员'&&bmButtons">
						<text>立即报名</text>
					</button>
					<button form-type="submit" @click="submit" class="btn" v-if="hyStatus=='尊贵大会员'&&bmButtons">
						<text>立即报名</text>
					</button>
				</view>
			</view>
		</view>
		<!-- 温馨提示弹窗 -->
		<!-- <uni-popup ref="popup" type="bottom" border-radius="10px 10px 0 0">
			<view class="popup">
				<view class="contentXy">
					<text>*注：</text>*注：若因您所提供的信息有误而导致保险无法正常理赔或产生其他相关问题，俱乐部将不承担任何责任。
				</view>
			</view>
		</uni-popup> -->
		<!-- 长按二维码进群弹窗 -->
		<uni-popup ref="qunpopup" type="bottom" border-radius="10px 10px 0 0">
			<view class="tit">  
					<view class="qText">
			            长按二维码加入组织
			        </view>  
			        <image show-menu-by-longpress="true" mode='widthFix' :src="imgUrl+info.qimage" class="btn-icon" @click="previewImage">  
			        </image>  
			    </view>  
		</uni-popup>
		<!-- 会员价格对比弹窗 -->
		<uni-popup ref="popupXy" type="bottom" border-radius="10px 10px 0 0">
			<view class="popup">
				<!-- 关闭窗口 -->
				<view class="gb">
					<image src="../../static/img/colse.png" mode="" class="colse" @click="colseXy"></image>
				</view>
				<!-- 会员弹窗 -->
				<view class="showBox">
					<!-- 普通用户 -->
					<view v-if="hyStatus=='普通用户'" class="openall pt">
						<view class="openN" v-if="hyStatus=='普通用户'">普通用户</view>
						<view class="openName" v-if="hyStatus=='普通用户'">
							<span class="jf" v-if="userIn.grade=='普通用户'||!userIn.grade">￥{{info.price*formData.length}}</span>
						</view>
						<view class="openbutBox">
							<view class="openbut" v-if="hyStatus=='普通用户' && bmButtons" form-type="submit" @click="submit">
								去报名
							</view>
						</view>
					</view>
					<!-- 普通会员弹窗 -->
					<view v-if="hyStatus=='普通用户'||hyStatus=='普通会员'"  class="openall pthy">
						<view class="openN" v-if="hyStatus=='普通用户'||hyStatus=='普通会员'">普通会员</view>
						<view class="openName" v-if="hyStatus=='普通用户'||hyStatus=='普通会员'">
							<span class="jf" v-if="formData.length==1">￥{{info.hyPrice*formData.length}}</span>
							<span class="jf" v-if="formData.length==2">￥{{parseFloat(info.hyPrice)+parseFloat(info.price)*0.9}}</span>
							<span class="jf" v-if="formData.length==3">￥{{parseFloat(info.hyPrice)+parseFloat(info.price)*0.9+parseFloat(info.price)*0.9}}</span>
						</view>
						<view class="openbutBox">
							<view class="openbut" form-type="submit" @click="submit" v-if="hyStatus=='普通会员'&&bmButtons">
								去报名
							</view>
							<view class="openbut" v-if="hyStatus!=='普通会员'" @click="tokt(3)">
								去开通
							</view>
						</view>
					</view>
					<!-- 尊贵大会员 -->
					<view v-if="hyStatus=='普通用户'||hyStatus=='普通会员'||hyStatus=='尊贵大会员'"  class="openall dhy">
						<view class="openN" v-if="hyStatus=='普通用户'||hyStatus=='普通会员'||hyStatus=='尊贵大会员'">尊贵大会员</view>
						<view class="openName" v-if="hyStatus=='普通用户'||hyStatus=='普通会员'||hyStatus=='尊贵大会员'">
							<span class="jf" v-if="formData.length==1">￥{{info.dPrice*formData.length}}</span>
							<span class="jf" v-if="formData.length==2">￥{{parseFloat(info.dPrice)+parseFloat(info.price)*0.9}}</span>
							<span class="jf" v-if="formData.length==3">￥{{parseFloat(info.dPrice)+parseFloat(info.price)*0.9+parseFloat(info.price)*0.9}}</span>
						</view>
						<view class="openbutBox">
							<view class="openbut" v-if="hyStatus!=='尊贵大会员'" @click="tokt(1)">
								去开通
							</view>
						</view>
					</view>
				</view>
			</view>
		</uni-popup>
		<!-- 人员信息 -->
		<uni-popup ref="infoPopup" type="bottom" border-radius="10px 10px 0 0">
			<view class="infoPopup">
				<view class="infoPopupO">
					<view class="infoItem" v-for='(item,index) in dzlist' v-if="userName!==item.name">
						<view class="infoname">{{item.name}}</view>
						<view class="infophone">{{item.phone}}</view>
						<view class="infobut" @click="handleAddxz(item)">选择</view>
					</view>
				</view>
				<view class="ttxry" @click="handleAdd" v-if="formData.length<=2&&info.isstart==0">
					<view class="jiat">
						<!-- <image src="../../static/img/jiahao.png" mode="" class="icon"></image> -->
						<text>添加新搭子</text>
					</view>
				</view>
			</view>
		</uni-popup>
	</view>
</template>

<script>
	import {
		bannerList,
		userInfo,
		hdDetails,
		hdbmAdd,
		getPhoneHy,
		getdzlist
	} from '@/api/api.js'
	import {
		memberDetails,getdyxx,getfsxx,getopenid } from '@/api/member.js'
	import {
		getPay,
		getEnrollTran
	} from '@/api/pay.js'
	import { fxUser } from '@/api/fx.js'
	import graceChecker from "@/api/graceChecker.js"
	import config from '@/config'
	export default {
		data() {
			return {
				imgUrl: config.baseUrl,
				id: "",
				inputValue: '',
				formData: [{
					name: "",
					card: "",
					phone: "",
				}],
				imgList: [],
				userId: "",
				orderId: "",
				openid: "",
				info: {},
				ym: "",
				startTime: "",
				endTime: "",
				date: "",
				price: "",
				orderInfo: {},
				paymentTrade: "",
				jfPrice: "",
				userIn:{},
				hyPrice:"",
				// 选中事件
				checkbox:false,
				// 禁止重复点击
				noClick: true,
				bmButtons:true,
				token:"",
				phone1:"",
				hyStatus:"",
				phone:"",
				dzlist:[],
				userName:""
			}
		},
		onLoad(options) {
			console.log('optionsoptionsoptions11',options)
			this.id = options.id,
			// 分销的电话
			this.phone1 = options.phone
			// this.banner();
			this.getUserInfo();
			this.getHd();
			// this.$refs.popup.open('center')
			// setTimeout(() => {
			// 	this.$refs.popup.close()
			// }, 15000); // 10000毫秒等于10秒
		},
		methods: {
			// 查询banner数据
			banner() {
				bannerList().then((res) => {
					if (res.code == 200) {
						for (let i = 0; i < res.data.length; i++) {
							this.imgList.push(this.imgUrl + res.data[i].image);
						}
					}
				})
			},

			// 查询活动详情
			getHd() {
				hdDetails(this.id).then((res) => {
					this.info = res.data
					this.price = this.info.price.replace(/\.00$/, '');
					const date = this.info.startTime; // 你可以根据需要更改这个日期
					this.date = this.getChineseWeekday(date);
					this.formatDate(date);
					this.endDate(this.info.endTime)
				})
			},
			
			// 价格对比弹窗
			handleEnroll(){
				// 校验身份证号
				let pattern = /^[1-9]\d{5}(18|19|20|21|22)?\d{2}(0[1-9]|1[0-2])(0[1-9]|[12]\d|3[01])\d{3}(\d|[Xx])$/;
				// 校验手机号
				let regex = /^1[3-9]\d{9}$/;
				let isValid = true;
				// 验证每个表单项
				this.idNumberError = !pattern.test(this.idNumber);
				if(this.formData.length==1){
					if (!this.formData[0].name) {
						isValid = false;
						// 这里可以添加具体的错误处理逻辑
						uni.showToast({
							title: '你的姓名不正确',
							icon: 'none',
						});
					} else if (!this.formData[0].card || !pattern.test(this.formData[0].card)) {
						isValid = false;
						// 这里可以添加具体的错误处理逻辑
						uni.showToast({
							title: '你的身份证号不正确',
							icon: 'none',
						});
					} else if(!this.checkbox){
						isValid = false;
						// 这里可以添加具体的错误处理逻辑
						uni.showToast({
							title: '请阅读免责声明',
							icon: 'none',
						});
					}else if (!this.formData[0].phone || !regex.test(this.formData[0].phone)) {
						isValid = false;
						// 这里可以添加具体的错误处理逻辑
						uni.showToast({
							title: '你的电话号码不正确',
							icon: 'none',
						});
					}else{
							this.$refs.popupXy.open('center')
						}
				}else if(this.formData.length==2){
					if (!this.formData[1].name) {
						isValid = false;
						// 这里可以添加具体的错误处理逻辑
						uni.showToast({
							title: '你第一个搭子的姓名不正确',
							icon: 'none',
						});
					} else if (this.formData[0].name == this.formData[1].name){
						isValid = false;
						// 这里可以添加具体的错误处理逻辑
						uni.showToast({
							title: '姓名不能一致',
							icon: 'none',
						});
						
					}else if (!this.formData[1].card || !pattern.test(this.formData[1].card)) {
						isValid = false;
						// 这里可以添加具体的错误处理逻辑
						uni.showToast({
							title: '你第一个搭子的身份证号不正确',
							icon: 'none',
						});
					} else if (this.formData[0].card == this.formData[1].card){
						isValid = false;
						// 这里可以添加具体的错误处理逻辑
						uni.showToast({
							title: '身份证号不能一致',
							icon: 'none',
						});
						
					}else if (!this.formData[1].phone || !regex.test(this.formData[1].phone)) {
						isValid = false;
						// 这里可以添加具体的错误处理逻辑
						uni.showToast({
							title: '你第一个搭子的电话号码不正确',
							icon: 'none',
						});
					}else if(!this.checkbox){
						isValid = false;
						// 这里可以添加具体的错误处理逻辑
						uni.showToast({
							title: '请阅读免责声明',
							icon: 'none',
						});
					}else{
							this.$refs.popupXy.open('center')
						}
				}else if(this.formData.length==3){
					if (!this.formData[2].name) {
						isValid = false;
						// 这里可以添加具体的错误处理逻辑
						uni.showToast({
							title: '你第二个搭子的姓名不正确',
							icon: 'none',
						});
					}else if (!this.formData[2].card || !pattern.test(this.formData[1].card)) {
						isValid = false;
						// 这里可以添加具体的错误处理逻辑
						uni.showToast({
							title: '你第二个搭子的身份证号不正确',
							icon: 'none',
						});
					}else if (!this.formData[2].phone || !regex.test(this.formData[2].phone)) {
						isValid = false;
						// 这里可以添加具体的错误处理逻辑
						uni.showToast({
							title: '你第二个搭子的电话号码不正确',
							icon: 'none',
						});
					}else if (this.formData[0].name == this.formData[2].name||this.formData[1].name == this.formData[2].name){
						isValid = false;
						// 这里可以添加具体的错误处理逻辑
						uni.showToast({
							title: '姓名不能一致',
							icon: 'none',
						});
						
					}else if (this.formData[0].card == this.formData[2].card||this.formData[1].card == this.formData[2].card){
						isValid = false;
						// 这里可以添加具体的错误处理逻辑
						uni.showToast({
							title: '身份证号不能一致',
							icon: 'none',
						});
						
					}else if(!this.checkbox){
						isValid = false;
						// 这里可以添加具体的错误处理逻辑
						uni.showToast({
							title: '请阅读免责声明',
							icon: 'none',
						});
					}else{
							this.$refs.popupXy.open('center')
						}
				}
			},
			
			// 关闭弹窗
			colseXy() {
				this.$refs.popupXy.close()
			},
			
			// 查询人员信息中是否存在该电话号码并赋值
			getUserInfo() {
				let userPhone = "";
				let userName = "";
				let userCard = "";
				let that = this
				uni.getStorage({
					key: 'data1',
					success: function(res) {
						if(res.data.openid){
							that.openid = res.data.openid
							that.phone = res.data.phone
							// 查询用户信息表中是否有该手机号
							userInfo(res.data.phone).then((res) => {
								if (res.info) {
									that.userIn = res.info
									that.userId = res.info.id
									that.jfPrice = res.info.integral * 0.02
									that.hyStatus = res.info.grade
									that.formData[0].phone = res.info.phone
									that.userName = res.info.userName
									if (res.info.userName) {
										that.formData[0].name = res.info.userName
									}
									if (res.info.card) {
										that.formData[0].card = res.info.card
									}
								}
							})
							// 延迟给手机号赋值
							// setTimeout(() => {
							// 	that.formData[0].phone = userPhone;
							// 	that.formData[0].name = userName;
							// 	that.formData[0].card = userCard
							// 	that.$forceUpdate();
							// }, 100);
							console.log('that.formDatathat.formData',that.formData)
						}else{
							uni.clearStorageSync();
							uni.showToast({
								title: '信息已过期，请重新登录',
								icon: 'none',
								duration: 2000
							})
							setTimeout(() => {
								console.log('跳转首页')
								uni.reLaunch({
									url: '/pages/login/login'
								 });
							}, 1000); // 10000毫秒等于10秒
						}
					}
				});
			},

			// 添加立即报名按钮调用formSubmit方法
			submit() {
				this.formSubmit()
			},
			
			// 身份校验
			toActivate(){
				
			},

			formSubmit: function(e) {
				// 校验身份证号
				let pattern = /^[1-9]\d{5}(18|19|20|21|22)?\d{2}(0[1-9]|1[0-2])(0[1-9]|[12]\d|3[01])\d{3}(\d|[Xx])$/;
				// 校验手机号
				let regex = /^1[3-9]\d{9}$/;
				let isValid = true;
				// 验证每个表单项
				this.idNumberError = !pattern.test(this.idNumber);
				if(this.formData.length==1){
					if (!this.formData[0].name) {
						isValid = false;
						// 这里可以添加具体的错误处理逻辑
						uni.showToast({
							title: '你的姓名不正确',
							icon: 'none',
						});
					} else if (!this.formData[0].card || !pattern.test(this.formData[0].card)) {
						isValid = false;
						// 这里可以添加具体的错误处理逻辑
						uni.showToast({
							title: '你的身份证号不正确',
							icon: 'none',
						});
					} else if(!this.checkbox){
						isValid = false;
						// 这里可以添加具体的错误处理逻辑
						uni.showToast({
							title: '请阅读免责声明',
							icon: 'none',
						});
					}else if (!this.formData[0].phone || !regex.test(this.formData[0].phone)) {
						isValid = false;
						// 这里可以添加具体的错误处理逻辑
						uni.showToast({
							title: '你的电话号码不正确',
							icon: 'none',
						});
					}else{
							this.getZf(this.formData)
						}
				}else if(this.formData.length==2){
					if (!this.formData[1].name) {
						isValid = false;
						// 这里可以添加具体的错误处理逻辑
						uni.showToast({
							title: '你第一个搭子的姓名不正确',
							icon: 'none',
						});
					} else if (this.formData[0].name == this.formData[1].name){
						isValid = false;
						// 这里可以添加具体的错误处理逻辑
						uni.showToast({
							title: '姓名不能一致',
							icon: 'none',
						});
						
					}else if (!this.formData[1].card || !pattern.test(this.formData[1].card)) {
						isValid = false;
						// 这里可以添加具体的错误处理逻辑
						uni.showToast({
							title: '你第一个搭子的身份证号不正确',
							icon: 'none',
						});
					} else if (this.formData[0].card == this.formData[1].card){
						isValid = false;
						// 这里可以添加具体的错误处理逻辑
						uni.showToast({
							title: '身份证号不能一致',
							icon: 'none',
						});
						
					}else if (!this.formData[1].phone || !regex.test(this.formData[1].phone)) {
						isValid = false;
						// 这里可以添加具体的错误处理逻辑
						uni.showToast({
							title: '你第一个搭子的电话号码不正确',
							icon: 'none',
						});
					}else if(!this.checkbox){
						isValid = false;
						// 这里可以添加具体的错误处理逻辑
						uni.showToast({
							title: '请阅读免责声明',
							icon: 'none',
						});
					}else{
							this.getZf(this.formData)
						}
				}else if(this.formData.length==3){
					if (!this.formData[2].name) {
						isValid = false;
						// 这里可以添加具体的错误处理逻辑
						uni.showToast({
							title: '你第二个搭子的姓名不正确',
							icon: 'none',
						});
					}else if (!this.formData[2].card || !pattern.test(this.formData[1].card)) {
						isValid = false;
						// 这里可以添加具体的错误处理逻辑
						uni.showToast({
							title: '你第二个搭子的身份证号不正确',
							icon: 'none',
						});
					}else if (!this.formData[2].phone || !regex.test(this.formData[2].phone)) {
						isValid = false;
						// 这里可以添加具体的错误处理逻辑
						uni.showToast({
							title: '你第二个搭子的电话号码不正确',
							icon: 'none',
						});
					}else if (this.formData[0].name == this.formData[2].name||this.formData[1].name == this.formData[2].name){
						isValid = false;
						// 这里可以添加具体的错误处理逻辑
						uni.showToast({
							title: '姓名不能一致',
							icon: 'none',
						});
						
					}else if (this.formData[0].card == this.formData[2].card||this.formData[1].card == this.formData[2].card){
						isValid = false;
						// 这里可以添加具体的错误处理逻辑
						uni.showToast({
							title: '身份证号不能一致',
							icon: 'none',
						});
						
					}else if(!this.checkbox){
						isValid = false;
						// 这里可以添加具体的错误处理逻辑
						uni.showToast({
							title: '请阅读免责声明',
							icon: 'none',
						});
					}else{
							this.getZf(this.formData)
						}
				}
			},

			// 支付-交易记录-报名信息
			getZf(formData) {
				if (this.noClick) {
					this.noClick = false;
					let data = [];
					
					for(let i=0;i<formData.length;i++){
						let haha = {
							name:formData[i].name,
							card:formData[i].card,
							phone:formData[i].phone,
						}
						data.push(haha);
					}
					
					let currentDate = "";
					let time = "";
					// 年月日
					let date = new Date();
					let year = date.getFullYear();
					let month = date.getMonth() + 1;
					let day = date.getDate();
					let hours = date.getHours()
					let minutes = date.getMinutes()
					let seconds = date.getSeconds()
					currentDate = `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
					formData[0].price = this.price
					let price = ""
					// 如果启用积分就打折，否则用原价
					if(this.info.switch == 1) {
						price = this.price - this.jfPrice
					}else if(this.userIn.grade=='普通会员'&&formData.length==1){
						price = this.info.hyPrice*formData.length
					}else if(this.userIn.grade=='普通会员'&&formData.length==2){
						price = parseFloat(this.info.hyPrice)+parseFloat(this.info.price)*0.9
					}else if(this.userIn.grade=='普通会员'&&formData.length==3){
						price = parseFloat(this.info.hyPrice)+parseFloat(this.info.price)*0.9+parseFloat(this.info.price)*0.9
					}else if(this.userIn.grade=='尊贵大会员'&&formData.length==1){
						price = this.info.dPrice
					}else if(this.userIn.grade=='尊贵大会员'&&formData.length==2){
						price = parseFloat(this.info.dPrice)+parseFloat(this.info.price)*0.9
					}else if(this.userIn.grade=='尊贵大会员'&&formData.length==3){
						price = parseFloat(this.info.dPrice)+parseFloat(this.info.price)*0.9+parseFloat(this.info.price)*0.9
					}else{
						price = this.price
					}
					let temp = {
						enrollTime: currentDate,
						hname: this.info.hdName,
						hid: this.info.id,
						name: this.formData[0].name,
						phone: this.formData[0].phone,
						card: this.formData[0].card,
						price: price,
						yjprice:this.info.price,
						gradeName: this.userIn.grade,
						openid: this.openid,
						payment_type: 1,
						people:JSON.stringify(data),
						size:formData.length,
					};
					// 支付订单
					getPay(temp).then((res) => {
						if (res) {
							if(res.code==500){
								uni.showToast({
									title: res.msg,
									icon: 'none',
								});
								return;
							}
							let info = res.data;
							let that = this
							let price = ""
							if(this.info.switch == 1) {
								price = this.price - this.jfPrice
							}else if(this.userIn.grade=='普通会员'){
								price = this.info.hyPrice*formData.length
							}else if(this.userIn.grade=='尊贵大会员'&&formData.length==1){
								price = this.info.dPrice
							}else if(this.userIn.grade=='尊贵大会员'&&formData.length==2){
								price = parseFloat(this.info.dPrice)+parseFloat(this.info.price)
							}else if(this.userIn.grade=='尊贵大会员'&&formData.length==3){
								price = parseFloat(this.info.dPrice)+parseFloat(this.info.price)+parseFloat(this.info.price)
							}else{
								price = this.price
							}
							that.paymentTrade = res.dataInfo
							// 调起支付接口
							uni.requestPayment({
								provider: "wxpay",
								appid: info.appId, // 微信开放平台 - 应用 - AppId，注意和微信小程序、公众号 AppId 可能不一致
								timeStamp: info.timeStamp, // 时间戳（单位：秒）
								package: info.package, // 固定值
								paySign: info.paySign, //签名
								signType: info.signType, // 签名算法，这里用的 MD5/RSA 签名
								nonceStr: info.nonceStr, // 随机字符串
								async success(res) {
									if (res.errMsg == 'requestPayment:ok') {
										temp.hy = ""
										temp.userPhone = that.phone1
										console.log('报名temptemptemp',temp)
										fxUser(temp).then((res) => {
										})
										uni.showToast({
											title: '报名成功',
											icon: 'success',
											duration: 2000
										})
										that.$refs.popupXy.close()
										that.bmButtons = false
										
										if(that.info.qimage){
											setTimeout(() => {
												that.$refs.qunpopup.open('center')
												setTimeout(() => {
													console.log('跳转首页')
													uni.reLaunch({
														url: '/pages/index/index'
													 });
												}, 30000); // 10000毫秒等于10秒
											}, 1000);
										}else{
											uni.reLaunch({
												url: '/pages/index/index'
											 });
										}
										// 订阅消息
										// const openid = that.openid
										// let openidData = {
										// 	openid : openid
										// }
										// getopenid(openidData).then((res) => {
										// 	if(res.code==201){
										// 		const tmplIds = ['wvHoFSFthbX-iRCyzdEVBgtVppo6BqrXzdju-bvyBQU']; // 从后台获取
										// 		console.log('this.openid',openid)
										// 		uni.requestSubscribeMessage({
										// 		  tmplIds: tmplIds,
										// 		  // 增加引导文案（iOS有效）
										// 		  withSubscriptions: true,
										// 		  success(res) {
										// 		   console.log('订阅成功1', res);
										// 			if(res[tmplIds[0]]=== 'accept'){
										// 				let data =  {
										// 					  openid: openid,
										// 					  subscribe_result: res
										// 					}
										// 				getdyxx(data).then((res) => {
										// 					if(that.info.qimage){
										// 						setTimeout(() => {
										// 							that.$refs.qunpopup.open('center')
										// 							setTimeout(() => {
										// 								console.log('跳转首页')
										// 								uni.reLaunch({
										// 									url: '/pages/index/index'
										// 								 });
										// 							}, 30000); // 10000毫秒等于10秒
										// 						}, 1000);
										// 					}else{
										// 						uni.reLaunch({
										// 							url: '/pages/index/index'
										// 						 });
										// 					}
										// 					// let data1 =  {
										// 					// 	  openid: openid,
										// 					// 	  template_id: 'wvHoFSFthbX-iRCyzdEVBgtVppo6BqrXzdju-bvyBQU',
										// 					// 	}
										// 					// // let that = this
										// 					// getfsxx(data1).then((res) => {
																
										// 					// })
										// 				})
										// 			}
										// 		  },
										// 		  fail(err) {
										// 			console.log('订阅失败', err);
										// 		  }
										// 		});
										// 		return;
										// 	}else{
										// 		if(that.info.qimage){
										// 			setTimeout(() => {
										// 				that.$refs.qunpopup.open('center')
										// 				setTimeout(() => {
										// 					console.log('跳转首页')
										// 					uni.reLaunch({
										// 						url: '/pages/index/index'
										// 					 });
										// 				}, 30000); // 10000毫秒等于10秒
										// 			}, 1000);
										// 		}else{
										// 			uni.reLaunch({
										// 				url: '/pages/index/index'
										// 			 });
										// 		}
										// 	}
										// })
									}
								},
								fail(e) {
									if (e.errMsg == "requestPayment:fail cancel") {
										uni.showToast({
											title: '取消支付',
											icon: 'none',
										});
									} else {
										uni.showToast({
											title: '取消失败',
											icon: 'error',
										});
									}
								}
							})
						}
					})
					console.log('this.noClick', this.noClick)
					setTimeout(() => {
						this.noClick = true;
						console.log('this.noClick1', this.noClick)
					}, 2000) //时间可以自己定义
				}
			},
			
			// 人员信息弹窗
			handleopen(){
				let data = {
					zfPhone:this.phone
				}
				getdzlist(data).then((res) => {
					if(res.code==200&&res.data.length>0){
						this.dzlist = res.data
						this.$refs.infoPopup.open('bottom');
					}else if(res.code==201){
						let prem = {
								hdname: "",
								card: "",
								phone: "",
							}
							this.formData.push(prem); // 添加一个新的空表单项
							this.price = this.info.price * this.formData.length
					}
					
				})
				
			},

			// form表单+1
			handleAdd() {
				let prem = {
					hdname: "",
					card: "",
					phone: "",
				}
					this.formData.push(prem); // 添加一个新的空表单项
					this.price = this.info.price * this.formData.length
					this.$refs.infoPopup.close()
				},
			// 选择的表单+1
			handleAddxz(item){
				console.log('item',item)
				let prem = {
						name: item.name,
						card: item.card,
						phone: item.phone,
					}
					this.formData.push(prem); // 添加一个新表单项
					this.price = this.info.price * this.formData.length
					this.$refs.infoPopup.close()
				
			},
			//关闭弹窗
			// colseXy() {
			// 	this.$refs.popup.close()
			// },
			
			tokt(id){
				uni.navigateTo({
					url: '../hy/xq?id='+id,
				});
			},
			
			// 我已阅读选中事件
			checkboxChange(e){
				// this.checkbox = e.detail.value
				if(e.detail.value.length>0){
					this.checkbox = true
				}else{
					this.checkbox = false
				}
			},

			// form表单-1
			handleDel(index) {
				let that = this
				uni.showModal({
					// title: '提示',
					content: '确定不带你的搭子了？',
					success: function(res) {
						if (res.confirm) {
							that.formData.splice(index, 1); // 移除指定索引的表单项
							that.price = that.info.price * index
							// 用户点击了确定按钮的相关逻辑可以放在这里
						} else if (res.cancel) {
							console.log('用户点击取消');
							// 用户点击了取消按钮的相关逻辑可以放在这里
						}
					}
				});
			},

			// 开始时间
			formatDate(date) {
				const dateObj = date instanceof Date ? date : new Date(date);
				const year = dateObj.getFullYear();
				const month = (dateObj.getMonth() + 1).toString().padStart(2, '0');
				const day = dateObj.getDate().toString().padStart(2, '0');
				const hours = dateObj.getHours();
				const minutes = dateObj.getMinutes();
				const seconds = dateObj.getSeconds();
				this.ym = `${month}-${day}`;
				this.startTime = `${hours.toString().padStart(2, '0')}:${minutes.toString().padStart(2, '0')}`;
			},
			// 结束时间
			endDate(date) {
				const dateObj = date instanceof Date ? date : new Date(date);
				const year = dateObj.getFullYear();
				const month = (dateObj.getMonth() + 1).toString().padStart(2, '0');
				const day = dateObj.getDate().toString().padStart(2, '0');
				const hours = dateObj.getHours();
				const minutes = dateObj.getMinutes();
				const seconds = dateObj.getSeconds();
				this.ym = `${month}-${day}`;
				this.endTime = `${hours.toString().padStart(2, '0')}:${minutes.toString().padStart(2, '0')}`;
			},

			// 周几计算
			getChineseWeekday(date) {
				const weekdays = ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六'];
				return weekdays[new Date(date).getDay()];
			},
			
			// 长按二维码进群
			previewImage() {  
				let qImg = this.imgUrl+this.info.qimage
				uni.previewImage({  
					// 需要预览的图片链接列表。若无需预览，可以注释urls  
					// urls: [qImg],  
					// 为当前显示图片的链接/索引值  
					current: qImg,  
					// 图片指示器样式    
					indicator: 'default',  
					// 是否可循环预览  
					loop: false,  
					success: res => {  
						console.log('previewImage res', res);  
					},  
					fail: err => {  
						console.log('previewImage err', err);  
					}  
				});  
			}

		}
	}
</script>

<style>
	/* .formBox{
		padding: 20rpx;
		box-shadow: 1px 1px 10px #ddd;
		width: 90%;
		margin: 10px auto 20px;
		border-top-left-radius: 10px;
		border-top-right-radius: 10px;
		background-color: #fff;
		box-shadow: 1px 1px 10px #ddd;
	} */

	.uni-input,
	.inputSelect {
		height: 60rpx;
		width: 300rpx;
		float: right;
		color: #8080a1;
	}

	.title {
		height: 60rpx;
		line-height: 60rpx;
		width: 250rpx;
		float: left;
	}

	.image button {
		font-size: 12px;
		width: 80px;
		background-color: #6a8473;
		color: #fff;
	}

	.uni-form-item {
		/* padding: 20rpx 0; */
		width: 100%;
		height: 60rpx;
		border-bottom: 1px solid #ddd;
		margin-top: 10px;
		font-size: 12px;
	}

	.uni-column {
		/* border: 1px solid red; */
		/* display: flex; */
	}

	.btn {
		background-color: #6a8473;
		color: #fff;
		height: 40px;
		line-height: 40px;
		font-size: 14px;
		margin-top: 10px;
		font-weight: 300;
	}

	.icon {
		width: 40rpx;
		height: 40rpx;
		position: relative;
		top: 14rpx;
		margin-right: 5px;
	}

	.txry {
		text-align: center;
		padding: 7rpx 0 26rpx;
		border-radius: 5px;
		margin-top: 10px;
		background-color: #6a8473;
		width: 96%;
		margin: 10px auto 0;
		font-weight: 300;
	}

	.txry i {
		color: #fff;
		font-size: 14px;
		position: relative;
		top: 7px;
	}
	
	.ttxry{
		text-align: center;
		/* padding: 7rpx 0 26rpx; */
		border-radius: 5px;
		margin-top: 10px;
		border: 1px dashed #698376;
		width: 96%;
		margin: 10px auto 0;
		font-weight: 300;
		padding: 16rpx 0;
		border: 1px dashed #698376;
		
	}
	
	.ttxry i{
		color: #698376;
		font-size: 14px;
		position: relative;
		top: 7px;
	}

	.jia {
		display: flex;
		width: 195rpx;
		margin: 0 auto;
	}
	
	.jia text{
		font-size: 26rpx;
		color: #fff;
		margin-top: 16rpx;
	}
	
	.jiat text{
		font-size: 26rpx;
		margin-top: 16rpx;
		color: #698376;
		font-weight: bold;
	}

	.uni-btn-v {
		background: #fff;
		position: fixed;
		bottom: 0;
		width: 100%;
		display: flex;
		padding: 0 10px;
	}

	.img {
		width: 16px;
		height: 16px;
		margin-top: 10px;
		position: relative;
		top: 4px;
		margin-right: 5px;
	}

	.hdXq {
		background: #fff;
		width: 90%;
		padding: 10px;
		margin: 10px auto 0;
		border: 1px solid #6a8473;
	}

	.hdTitle {
		font-weight: 300;
		font-size: 28rpx;
	}

	.hdText {
		font-weight: 300;
		font-size: 24rpx;
	}

	.form {
		background: #fff;
		width: 90%;
		margin: 15px auto 0;
		padding: 10px;
		display: block;
		position: relative;
		padding-bottom: 17px;
		border: 1px solid #6a8473;
	}

	.price {
		line-height: 57px;
		width: 60%;
		color: #6a8473;
		font-size: 32rpx;
		font-weight: 300;
	}

	.del {
		width: 25px;
		height: 25px;
		position: absolute;
		right: -5px;
		top: -8px;
	}

	.height {
		height: 70px;
	}

	.jf {
		/* color: red; */
		/* font-size: 24rpx; */
		margin-left: 20rpx;
	}

	.tishi {
		padding: 10rpx 20rpx;
		color: red;
		font-size: 24rpx;
	}

	.colse {
		width: 40rpx;
		height: 40rpx;
		float: right;
	}

	.popup {
		background: #fff;
		width: 500rpx;
		padding: 20rpx;
		font-size: 26rpx;
		/* border-radius: 20rpx; */
		margin: 0 auto;
		line-height: 47rpx;
		/* text-align: center; */
		font-weight: 300;
	}
	
	.popup text{
		color: red;
	}

	.vue-ref {
		padding-bottom: 0 !important;
	}
	
	/* 长按二维码进群 */
	.tit {  
		text-align: center;  
		margin: 15px auto;  
		background-color: #fff;
		padding: 20rpx;
		border-radius: 15rpx;
	}  

	.btn-icon {  
		display: block;  
		height: 794rpx;  
		width: 630rpx;  
		margin: 15px auto;  
	}  
	
	.shengming{
		color: red;
		font-size: 24rpx;
		padding: 20rpx;
		line-height: 45rpx;
	}
	
	.xy{
		font-size: 24rpx;
		text-align: center;
	}
	
	.colse {
		width: 16px;
		height: 16px;
		position: absolute;
		right: 15px;
	}
	
	.openall{
		display: flex;
		margin-top: 20rpx;
		border-radius: 10rpx;
		padding: 10rpx 20rpx;
	}
	.openbut{
		color: #fff;
	}
	
	.openbutBox{
		margin-left: auto;
	}
	
	.pt{
		background: #698376;
	}
	
	.pthy{
		background: #eec2b0;
	}
	
	.dhy{
		background: #f1b74a;
	}
	
	.showBox{
		color: #fff;
		margin-top: 50rpx;
	}
	
	.openN{
		margin-right: 14rpx;
		width: 135rpx;
	}
	
	.infoPopup{
		background-color: #fff;
		width: 95%;
		height: 500rpx;
		padding: 20rpx;
	}
	
	.infoItem{
		border-bottom: 1px solid #698376;
		margin: 10rpx 0;
		font-size: 24rpx;
		padding: 10rpx;
		text-align: center;
		display: flex;
	}
	
	.infoItem view{
		width: 32%;
	}
	
	.infophone{
		text-align: center;
	}
	
	.infobut {
		color: #698376;
		text-align: right;
		font-weight: bold;
	}
	
	.infoname{
		text-align: left;
	}
	
	.infoPopupO{
	height: 400rpx;
	overflow: auto;
	}
	
	
	
</style>